Begin
// get zone as square with "radius" A around hero position
A := 10;
HX := GetInt('Hero.X');
HY := GetInt('Hero.Y');
if (HX - A) < 0 then
  BX := 0
else
  BX := HX - A;
if (HY - A) < 0 then
  BY := 0
else
  BY := HY - A;
X := GetInt('Map.X');
Y := GetInt('Map.Y');
if (HX + A) < X then
  X := HX + A
else
  X := X - 1;
if (HY + A) < Y then
  Y := HY + A
else
  Y := Y - 1;

InitAIMove(Bx, By, x, y);

for I := BX to X do
  for J := BY to Y do
    if Cell(4, I, J) <> 0 then
      if (abs(HX - I) > 1) or (abs(HY - J) > 1) then
      begin
        B := GetmobParam(i, j, 4);
        if (abs(HX - I) <= B) and (abs(HY - J) <= B) then
        begin
          // spiders set their web on the path
          if GetmobParam(i, j, 107) >= 0 then
            if Cell(1, I, J) = 0 then
              SetCell(1, I, J, 49);
          AIMove(I, J, Hx, Hy, True);
        end;
      end
      else
      begin
        SetInt('Monster.X', I);
        SetInt('Monster.Y', J);
        Run('Battles\Battle.pas');
        SetInt('Monster.X', -1);
        SetInt('Monster.Y', -1);
      end
    else
      if Cell(5, I, J) <> 0 then
      begin
        B := GetNpcParam(i, j, 4);
        C := GetNpcParam(i, j, 5);
        AIMove(I, J, B, C, True);
      end;
end
